import Vue from 'vue';
// import animated from 'animate.css';
import {
  Button,
  Loading,
  ImagePreview,
  Lazyload,
  Icon,
  Swipe,
  SwipeItem,
  Tabs,
  PullRefresh,
  List,
  Tab,
  Popup,
  Calendar,
  Uploader,
  Search
} from 'vant';
import router from './router';
import store from './store';
import App from './App.vue';
import './styles/index.css';
import 'vant/lib/index.css';
import loading from './plugins/loading';
import touch from './plugins/touch';
import ToastPlugin from './plugins/Toast2/index';
import CustomToast from './components/CustomToast/index';
import './utils/rem';
import 'pdfh5/css/pdfh5.css';
import './filters';

Promise.prototype.finally = function(callback) {
  let P = this.constructor;
  return this.then(
    value => P.resolve(callback()).then(() => value),
    reason =>
      P.resolve(callback()).then(() => {
        throw reason;
      })
  );
};

Vue.use(Button)
  .use(Loading)
  .use(ImagePreview)
  .use(Lazyload)
  .use(Swipe)
  .use(SwipeItem)
  .use(Icon)
  .use(Tabs)
  .use(Tab)
  .use(PullRefresh)
  .use(List)
  .use(Popup)
  .use(Uploader)
  .use(Search)
  .use(Calendar);

// Vue.use(animated);
Vue.use(loading);
Vue.use(touch);
Vue.use(ToastPlugin);
Vue.use(CustomToast);

Vue.config.productionTip = false;

const vueApp = new Vue({
  router,
  render: h => h(App),
  store
}).$mount('#app');

console.log('vueApp===', vueApp);

export default vueApp;
